
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta charset="UTF-8">
		<meta name="Generator" content="EditPlus®">
		<meta name="Author" content="">
		<meta name="Keywords" content="">
		<meta name="Description" content="">
		<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
		<meta name="renderer" content="webkit">

		@if( empty($sate) )
		<link rel="shortcut icon" type="image/x-icon" href="{{ asset('icon/favicon.ico') }}">
		<title>当你看到这个title的时候，就是你们的模块没有查询sates表</title>
		@else
		<link rel="shortcut icon" type="image/x-icon" href="http://oydt3ttm3.bkt.clouddn.com/{{ $sate['icon'] }}">
		<title>{{ $sate['name'] }}</title>
		@endif

		<script type="text/javascript" src="{{ asset('js/jquery.js') }}"></script>
		<script type="text/javascript" src="{{ asset('js/jcarousellite.js') }}"></script>

		<link href="{{ asset('css/cartstyle.css') }}" rel="stylesheet" type="text/css" />
		<link href="{{ asset('css/optstyle.css') }}" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" type="text/css" href="{{ asset('css/base.css') }}">
		<link rel="stylesheet" type="text/css" href="{{ asset('css/home.css') }}">
		<link rel="stylesheet" type="text/css" href="{{ asset('css/newcart.css') }}">
		<!-- <link rel="stylesheet" type="text/css" href="{{ asset('css/demo.css') }}"> -->

		<script type="text/javascript" src="{{ asset('js/jquery.js') }}"></script>


	</head>

	<body>

		<!--顶部导航条 -->
<header id="pc-header">
	<div class="BHeader">
        <div class="yNavIndex">
            <ul class="BHeaderl">
			  @if (session('Homeuser-data'))
			  @php $user = Session::get('Homeuser-data')  @endphp
			  <li><a href="{{ route('home.user') }}" style="color:#ea4949;">{{ $user['username'] }}</a> </li>
			  <li class="headerul">|</li>
			  <li><a href="{{ route('loginout') }}">退出登录</a> </li>
			  <li class="headerul">|</li>
			  <li><a href="{{ route('orderlist') }}">订单查询</a> </li>
			  <li class="headerul">|</li>
			  <li><a href="{{ route('Home.goodsstow') }}">我的收藏</a> </li>
			  <li class="headerul">|</li>
			  <li id="pc-nav" class="menu"><a href="{{ route('Home.index') }}" class="tit">我的商城</a>
				  <div class="subnav">
					  <a href="{{ route('orderlist') }}">我的订单</a>
					  <a href="my-s.html">我的收藏</a>
					  <a href="{{ route('home.user') }}l">账户安全</a>
					  <a href="{{ route('user.address') }}">地址管理</a>
					  <a href="{{ route('user.edit') }}">编辑信息</a>
				  </div>
			  </li>
			  @else
			  <li><a href="{{ route('home.login') }}" style="color:#ea4949;">请登录</a> </li>
			  <li class="headerul">|</li>
			  <li><a href="{{ route('home.register') }}">免费注册</a> </li>
			  </li>
			  @endif


            </ul>
        </div>
    </div>
</header>

			<!--悬浮搜索框1-->

			<div class="nav white">

				<div class="logoBig" style="margin-left:300px">
					@if(empty($sate))
					<img src="{{ asset('icon/logo.png') }}">
					@else
					<a href="{{ route('Home.index') }}"><img src="http://oydt3ttm3.bkt.clouddn.com/{{ $sate['logo'] }}" style="width:190px"></a>
					@endif
				</div>
			</div>

			<div class="clear"></div>



			<!--购物车 -->
			<div class="concent">
				<div class="container clearfix">
       	 			<div class="pc-order-titlei fl"><h2>我的购物车</h2></div>
    			</div>
				<div id="cartTable">
					<div class="cart-table-th">
						<div class="wp">
							<div class="th th-chk">
								<div id="J_SelectAll1" class="select-all J_SelectAll">

								</div>
							</div>
							<div class="th th-item" style="width:410px">
								<div class="td-inner">商品信息</div>
							</div>
							<div class="th th-price">
								<div class="td-inner">单价</div>
							</div>
							<div class="th th-amount">
								<div class="td-inner">数量</div>
							</div>
							<div class="th th-sum">
								<div class="td-inner">金额</div>
							</div>
							<div class="th th-op" style="float:left">
								<div class="td-inner" style="display:block">操作</div>
							</div>
						</div>
					</div>
					<div class="clear"></div>

					@if (empty($cartInfos))
					<tr class="item-list" style="height:50px">
						<div class="bundle  bundle-last " style="width:1297px">
							<ul class="item-content clearfix">
								<p style="text-align:center;margin-top:50px;font-size:3em">暂无商品，逛逛别的吧~</p>
							</ul>
						</div>
					</tr>
					@else

					@foreach ($cartInfos as $cartInfo)
					<tr class="item-list">
						<div class="bundle  bundle-last " style="width:1297px">

							<div class="clear"></div>
							<div class="bundle-main">
								<ul class="item-content clearfix">
									<li class="td td-chk">
										<div class="cart-checkbox ">
											<input class="check" id="J_CheckBox_170037950254" name="items" value="{{ $cartInfo['attr_id'] }}" type="checkbox" checked>
											<label for="J_CheckBox_170037950254"></label>
										</div>
									</li>
									<li class="td td-item">
										<div class="item-pic">
											<a href="#" target="_blank" data-title="{{ $cartInfo['name'] }}" class="J_MakePoint" data-point="tbcart.8.12">
												<img src="http://oydt3ttm3.bkt.clouddn.com/{{ $cartInfo['pic'] }}" class="itempic J_ItemImg" style="width:80px;heiht:80px">
											</a>
										</div>
										<div class="item-info">
											<div class="item-basic-info">
												<a href="#" target="_blank" title="{{ $cartInfo['desc'] }}" class="item-title J_MakePoint" data-point="tbcart.8.11">{{ $cartInfo['name'] }}</a>
											</div>
										</div>
									</li>
									<li class="td td-info" style="position:absolute;left:100px;">
										<div class="item-props item-props-scan">
											<span class="sku-line">颜色：{{ $cartInfo['color'] }}</span>
											<span class="sku-line">尺寸：{{ $cartInfo['size'] }}码</span>
											<i class="theme-login am-icon-sort-desc"></i>
										</div>
									</li>
									<li class="td td-price">
										<div class="item-price price-promo-promo">
											<div class="price-content">

												<div class="price-line">
													<em class="J_Price price-now" tabindex="0">{{ $cartInfo['price'] }}</em>
												</div>
											</div>
										</div>
									</li>
									<li class="td td-amount">
										<div class="amount-wrapper ">
											<div class="item-amount ">
												<div class="sl">
													<input class="min am-btn" style="width:20px;height:23px" name="" type="button" onclick="num_cut(this, {{ $cartInfo['attr_id'] }})" value="-" />
													<input class="text_box" name="" type="text" value="{{ $cartInfo['num'] }}" style="width:30px;" disabled />
													<input class="add am-btn" style="width:20px;height:23px" name="" type="button" onclick="num_add(this, {{ $cartInfo['attr_id'] }})" value="+" />
												</div>
											</div>
										</div>
									</li>
									<li class="td td-sum">
										<div class="td-inner">
											<em tabindex="0" class="J_ItemSum number">{{ $cartInfo['money'] }}</em>
										</div>
									</li>
									<li class="td td-op">
										<div class="td-inner">
											@auth
												@stow( $cartInfo['goods_id'])
												<a title="移入收藏夹" class="btn-fav" href="javascript:;" onclick="goods_stow(this, {{ $cartInfo['goods_id'] }})">移入收藏夹</a>
												@elsestow
												<a href="javascript:;" class="btn-fav">已收藏</a>
												@endstow
											@endauth
											<!-- <a href="javascript:;" data-point-url="#" class="delete" > -->
											<a href="javascript:;" data-point-url="#" onclick="goods_del(this, {{ $cartInfo['attr_id'] }})">
                  					删除</a>
										</div>
									</li>
								</ul>


							</div>
						</div>
					</tr>

					@endforeach
					@endif

					<div class="clear"></div>


				</div>
				<div class="clear"></div>

				<div class="float-bar-wrapper">
					<div id="J_SelectAll2" class="select-all J_SelectAll">
						<div class="cart-checkbox">

						</div>
					</div>
					<div class="float-bar-right">
						<div class="amount-sum">
							<span class="txt">已选商品</span>
							<em id="J_SelectedItemsCount">0</em>
							<span class="txt">件</span>
							<div class="arrow-box">
								<span class="selected-items-arrow"></span>
								<span class="arrow"></span>
							</div>
						</div>
						<div class="price-sum">
							<span class="txt">合计:</span>
							<strong class="price">¥<em id="J_Total">{{ $total }}</em></strong>
						</div>
						@if (empty($cartInfos))
						@else
						<div class="btn-area">
							<a id="J_Go" class="submit-btn submit-btn-disabled" aria-label="请注意如果没有选择宝贝，将无法结算">
								<span class="account">结&nbsp;算</span></a>
						</div>
						@endif
					</div>

					<div class="operations">
						<a hidefocus="true">全选　</a>
						<a hidefocus="true">反选　</a>
						<a hidefocus="true">删除　</a>
						<a hidefocus="true" class="J_BatchFav">移入收藏夹</a>
					</div>
				</div>


			</div>

			<!--操作页面-->


		<!--引导 -->
		<div class="aui-footer-bot">
		    <ul class="time-lists aui-footer-pd clearfix" style="padding:50px;width:550px">
		        <li class="aui-footer-list clearfix" style="padding-left:90px">
		            <h4>
		                <span><img src="{{ asset('icon/icon-d1.png') }}"></span>
		                <em>消费者权益</em>
		            </h4>
		        </li>
		        <li class="aui-footer-list clearfix" style="padding-left:10px">
		            <h4>
		                <span><img src="{{ asset('icon/icon-d2.png') }}"></span>
		                <em>新手上路</em>
		            </h4>
		        </li>
		        <li class="aui-footer-list clearfix" style="padding-left:10px">
		            <h4>
		                <span><img src="{{ asset('icon/icon-d3.png') }}"></span>
		                <em>保障正品</em>
		            </h4>
		        </li>
		    </ul>
		    <div style="border-bottom:1px solid #dedede"></div>
		    <div class="time-lists aui-footer-pd time-lists-ls clearfix">

				@if (!empty($linksArray))
		        <div class="aui-footer-list clearfix">
		            <h4>友情链接</h4>
		            <ul>
		                @foreach ($linksArray as $linkArray)
		                <li><a href="{{ $linkArray['url'] }}"> {{ $linkArray['name'] }} </a> </li>
		                @endforeach
		            </ul>
		        </div>
		        @else
		        <div class="aui-footer-list clearfix">
		            <ul>
		                <li><a href="#">如果你看到这个 </a> </li>
		                <li><a href="#"> 请在你的相应控制器内调用 </a> </li>
		                <li><a href="#"> app\Http\Controllers\Home\ShowLinksController@index方法</a> </li>
		                <li><a href="#"> 返回友情链接数组，并显示在前台 </a> </li>
		            </ul>
		            <h4>友情链接</h4>
		        </div>
		        @endif
		    </div>
		</div>


	</body>
	<script>

	</script>
	<script type="text/javascript">

	{{-- 显示购物车被勾选的商品数量的总价 --}}
	var itemsList = document.getElementsByName('items');
	var money = 0;
	var length = 0;
	for(var i = 0; i < itemsList.length; i++) {
		if (itemsList[i].checked == true) {
			length += 1;
			money += parseInt($(itemsList[i]).parent().parent().parent().children().last().prev().text());
		}
	}
	$('#J_SelectedItemsCount').text(length);
	$('#J_Total').text(money);

	{{-- 处理复选框点击的时候统计选中的商品数量和总价 --}}
	$('.check').click(function() {
		var itemsList = document.getElementsByName('items');
		var n = 0;
		var money = 0;
		for(var i = 0; i < itemsList.length; i++) {
			if (itemsList[i].checked == true) {
				n += 1;
				money += parseInt($(itemsList[i]).parent().parent().parent().children().last().prev().text());
			}
		}
		$('#J_SelectedItemsCount').text(n);
		$('#J_Total').text(money);
	});




	{{--全选反选删除--}}
	$('.operations').children().first().click(function() {
		$('.cart-checkbox  input[type="checkbox"]').prop('checked', true);

		var itemsList = document.getElementsByName('items');
		var money = 0;
		var length = 0;
		for(var i = 0; i < itemsList.length; i++) {
			if (itemsList[i].checked == true) {
				length += 1;
				money += parseInt($(itemsList[i]).parent().parent().parent().children().last().prev().text());
			}
		}
		$('#J_SelectedItemsCount').text(length);
		$('#J_Total').text(money);

	}).next().click(function() {
		$('.cart-checkbox  input[type="checkbox"]').each(function() {
			this.checked = !this.checked;
		});

		var itemsList = document.getElementsByName('items');
		var money = 0;
		var length = 0;
		for(var i = 0; i < itemsList.length; i++) {
			if (itemsList[i].checked == true) {
				length += 1;
				money += parseInt($(itemsList[i]).parent().parent().parent().children().last().prev().text());
			}
		}
		$('#J_SelectedItemsCount').text(length);
		$('#J_Total').text(money);

	}).next().click(function() {

		$('.cart-checkbox  input[type="checkbox"]:checked').each(function() {
			{{-- 通过把商品ID赋值给单选框的value，再把选中的单选框的value遍历传递给后台，就可以批量删除购物车里面的商品 --}}

			{{-- 判断用户有没有改过id，改过就直接弹窗警告 --}}
			$.ajax({
				type: 'get',
				dataType: 'json',
				data: 'attr_id=' + this.value,
				url: '{{ route("deletecartgoods") }}',
				success: function(data) {
					if (data.status == 404) {
						alert(data.msg);
					}

					if (data.status == 200) {
						$(this).parent().parent().parent().parent().parent().remove();
					}
				}
			});
		})

		var itemsList = document.getElementsByName('items');
		var money = 0;
		var length = 0;
		for(var i = 0; i < itemsList.length; i++) {
			if (itemsList[i].checked == true) {
				length += 1;
				money += parseInt($(itemsList[i]).parent().parent().parent().children().last().prev().text());
			}
		}
		$('#J_SelectedItemsCount').text(length);
		$('#J_Total').text(money);

		$('.cart-checkbox  input[type="checkbox"]:checked').parent().parent().parent().remove();
	});

	{{-- 单个删除--}}
	function goods_del(obj, attr_id) {
		{{-- 判断用户有没有改过id，改过就直接弹窗警告 --}}
		$.ajax({
			type: 'get',
			dataType: 'json',
			data: 'attr_id=' + attr_id,
			url: '{{ route("deletecartgoods") }}',
			success: function(data) {
				if (data.status == 404) {
					alert(data.msg);
				}

				if (data.status == 200) {
					alert(data.msg);
					$(obj).parent().parent().parent().parent().parent().remove();
				}
			}
		});
	}


	{{-- 商品加加 --}}
	function num_add(obj, attr_id) {
		{{-- 同理也要判断是否跟别处的id，value值是否相同，否则就警告 --}}
		$.ajax({
			type: 'get',
			dataType: 'json',
			data: 'attr_id=' + attr_id,
			url: '{{ route("cartgoodsadd") }}',
			success: function(data) {
				if (data.status == 404) {
					alert(data.msg);
				}

				if (data.status == 200) {
					$(obj).prev().val(data.num);
					$(obj).parent().parent().parent().parent().next().children().first().children().first().text(data.money);
					{{--
					$('#J_Total').text(data.total);
					--}}

					var itemsList = document.getElementsByName('items');
					var money = 0;
					var length = 0;
					for(var i = 0; i < itemsList.length; i++) {
						if (itemsList[i].checked == true) {
							length += 1;
							money += parseInt($(itemsList[i]).parent().parent().parent().children().last().prev().text());
						}
					}
					$('#J_SelectedItemsCount').text(length);
					$('#J_Total').text(money);

				}
			}

		});
	}

	{{-- 商品减减 --}}
	function num_cut(obj, attr_id) {
		{{-- 同理也要判断是否跟别处的id，value值是否相同，否则就警告 --}}
		$.ajax({
			type: 'get',
			dataType: 'json',
			data: 'attr_id=' + attr_id,
			url: '{{ route("cartgoodscut") }}',
			success: function(data) {
				if (data.status == 404) {
					alert(data.msg);
				}

				if (data.status == 200) {
					$(obj).next().val(data.num);
					$(obj).parent().parent().parent().parent().next().children().first().children().first().text(data.money);
					{{--
					$('#J_Total').text(data.total);
					--}}

					var itemsList = document.getElementsByName('items');
					var money = 0;
					var length = 0;
					for(var i = 0; i < itemsList.length; i++) {
						if (itemsList[i].checked == true) {
							length += 1;
							money += parseInt($(itemsList[i]).parent().parent().parent().children().last().prev().text());
						}
					}
					$('#J_SelectedItemsCount').text(length);
					$('#J_Total').text(money);


				}
			}

		});
	}

	$('.account').click(function() {
		{{-- 通过把商品ID赋值给单选框的value，再把选中的单选框的value遍历传递给后台，就可以得到购物车里面被选中的商品 --}}
		var attr_ids = '';
		$('.cart-checkbox  input[type="checkbox"]:checked').each(function() {
			attr_ids += this.value + ',';
		})

		{{-- 判断用户有没有改过id，改过就直接弹窗警告，后续有时间了再处理 --}}
		$.ajax({
			type: 'get',
			dataType: 'json',
			data: 'attr_ids=' + attr_ids,
			url: '{{ route("account") }}',
			success: function(data) {
				if (data.status == 404) {
					alert(data.msg);
					location.href = 'login';
				}
				if (data.status == 403) {
					alert(data.msg);
				}
				if (data.status == 402) {
					alert(data.msg);
					location.href = 'user/address';
				}
				if (data.status == 200) {
					alert(data.msg);
					location.href = 'confirm';
				}
			}
		});

	});

	function goods_stow(obj, goods_id) {

		if(goods_id) {
			$.get('{{ route('addgoodsstow')}}', {'goods_id': goods_id}, function(data){
					if (data.status == 200) {
						str = '<a href="javascript:;" class="btn-fav">已收藏</a>';
						$(obj).parent().prepend(str);
						$(obj).remove();
					}
			}, 'json');
		}

	}





	var timer = null;

    $('.gotop').click(function(){

        timer = setInterval(function() {
            // 解决兼容性获取滚动条距离
            var st = $(document).scrollTop();

            var speed = (0 - st) / 8;

            // 速度不能是小数
            speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);

            // 如果到达终点则停止
            if (st == 0) {
                clearInterval(timer);
            } else {
                // 移动 需要兼容设置
                $(document).scrollTop(st + speed);

            }
        }, 30);


    });

         (function(a){
         a.fn.hoverClass=function(b){
             var a=this;
             a.each(function(c){
                 a.eq(c).hover(function(){
                     $(this).addClass(b)
                 },function(){
                     $(this).removeClass(b)
                 })
             });
             return a
         };
     })(jQuery);

     $(function(){
         $("#pc-nav").hoverClass("current");
     });



	</script>

</html
